package knowlodges.designpattern;

public class TestSingleton {

    public static void main(String[] args) {
        //通过new实例化会报错
        //GiantDragon g = new GiantDragon();

        //只能通过getInstance得到对象
        Singleton g1 = Singleton.getInstance();
        Singleton g2 = Singleton.getInstance();
        Singleton g3 = Singleton.getInstance();

        //都是同一个对象
        System.out.println(g1 == g2);
        System.out.println(g1 == g3);
    }
}
